package cn.zjq.unilityclass.kehouzuoye.one;

import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        boolean flag = true;
        do {
        System.out.println("请输入你的邮箱号：");
        String emailNum = input.next();
        int index1 = emailNum.indexOf("@");
        int index2 = emailNum.indexOf(".");
            System.out.println("index1="+index1+"index2="+index2);
        if (index1 != -1 && index2 != -1) {
            if (index1 != 0 && index2 != 0) {
                if(index1 != (emailNum.length() - 1) && index2 != index1 ){
                    if (index1<index2&&index2-index1>=1){
                        System.out.println("登录成功");
                        flag = false;
                    }else{
                        System.out.println("邮箱的\"@\"符号必须在\".\"之前，且\"@\"符号和\".\"符号中间至少要有一个字符");
                    }
                }else{
                    System.out.println("\"@\"和\".\"" + "不能位于末端");
                }
            }else{
                System.out.println("\"@\"和\".\"" + "不能位于第一个位置");
            }
        }else{
            System.out.println("邮箱必须包含" + "\"@\"和\".\"");
        }
    }while(flag);
    }
}
